public class Test {
    public static void main(String[] args) {
        Swimming student =  new Swimming() {
            @Override
            public void swim() {
                System.out.println("学生游泳");
            }
        };
        go(student);

        System.out.println("--------------------");

        go(new Swimming() {
            @Override
            public void swim() {
                System.out.println("老师游泳");
            }
        });
    }

    static void go(Swimming s){
        System.out.println("开始");
        s.swim();
        System.out.println("结束");
    }

}

//class Student implements Swimming{
//    @Override
//    public void swim() {
//        System.out.println("学生游泳");
//    }
//}

interface Swimming{
    void swim();
}
